//导入创建服务器
const express = require("express");
const app = express();

//服务器挂载中间件，解决跨域问题
const cors = require('cors')
app.use(cors())

//服务器挂载中间件，配置解析
const bodyParser = require('body-parser')
app.use(bodyParser.json())
app.use(express.urlencoded({ extended: false }))

//设置路由
//1、登录和注册
const adminRouter = require('./router/admin')
app.use('/api/admin', adminRouter)

//导入user信息路由
const userinfoRouter = require('./router/userinfo')
app.use('/api/user', userinfoRouter)

//导入funds信息路由
const fundsRouter = require('./router/funds')
app.use('/api/funds', fundsRouter)

//导入mall信息路由
const mallRouter = require('./router/mall')
app.use('/api/mall', mallRouter)

//导入phone信息路由
const phoneRouter = require('./router/phone')
app.use('/api/phone', phoneRouter)


app.listen(3007, function() {
    console.log('api server running at http://127.0.0.1:3007')
})